﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Engine.CustomControls
{   
    public partial class WebMap : System.Windows.Forms.WebBrowser
    {
        public enum MapType : short
        {
            Google = 1,
            Waze = 2
        };


        

        private Maps.Google.MapCommands cmd;

        public WebMap()
        {
            InitializeComponent();
            this.ScrollBarsEnabled = false;
            this.DocumentCompleted+=new WebBrowserDocumentCompletedEventHandler(WebMap_DocumentCompleted);
            cmd = new Maps.Google.MapCommands();
            ObjectForScripting = cmd;
            
        }


        private void WebMap_DocumentCompleted(object sener, WebBrowserDocumentCompletedEventArgs e)
        {
            cmd.SetDocument(Document);
        }

        #region Properties

        /// <summary>
        /// Suported google maps commands
        /// </summary>
        public Maps.Google.MapCommands Commands
        {
            get { return cmd; }            
        }

        #endregion

        public void LoadMap(MapType type)
        {
            switch (type)
            {
                case MapType.Google:
                    {
                        this.Navigate(Application.StartupPath + "\\Maps\\Google\\map.htm"); break;
                    }
                case MapType.Waze:
                    {
                        throw new NotImplementedException("Waze maps are not supported yet");
                    }
            }
        }    

       
    }
}
